package com.markedquilt.controller;/*
 * PackageName: com.markedquilt.controller
 * Author:   coke
 * Date:     Created in 2020/10/25 14:11
 * Description:
 * History:
 * <author>        <time>             <version>          <desc>
 * 作者姓名         修改时间            版本号              描述
 * coke           2020/10/25 14:11     1.0
 */

import com.markedquilt.pojo.Account;
import com.markedquilt.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author ZhangKe
 * @Description
 * @date 2020/10/25 14:11.
 */
@Controller
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/queryAll")
    public String login(@RequestParam("name")String userName, @RequestParam("password")String password,
                        HttpServletRequest request, HttpServletResponse response) throws Exception {
        if (userName.equals("admin") && password.equals("admin")){
            List<Account> accounts = accountService.queryAccountList();
            request.setAttribute("accouts",accounts);
            return "/success.jsp";
        }else{
            return "/failt.jsp";
        }
    }
}
